//
//  MainTableViewCell.m
//  Tongcheng
//
//  Created by   丛熠超 on 2017/4/5.
//  Copyright © 2017年 Tongcheng. All rights reserved.
//

#import "MainTableViewCell.h"
#import "UIImageView+AFNetworking.h"

@interface MainTableViewCell()

@property (weak, nonatomic) IBOutlet UIImageView *IconImageview;
@property (weak, nonatomic) IBOutlet UILabel *NameLB;
@property (weak, nonatomic) IBOutlet UILabel *AgeLB;
@property (weak, nonatomic) IBOutlet UILabel *HeightLB;
@property (weak, nonatomic) IBOutlet UILabel *CityLB;
@property (weak, nonatomic) IBOutlet UIButton *sayHiBtn;
- (IBAction)sayhiBtnClick:(id)sender;

@end

@implementation MainTableViewCell

- (void)setIndexPath:(NSIndexPath *)indexPath
{
    _indexPath = indexPath;
}

- (void)setModel:(NearByListModel *)model
{
    _model = model;
    [self.IconImageview setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:nil];
    self.NameLB.text = model.user_nicename;
    self.HeightLB.text = [NSString stringWithFormat:@"%@cm", model.height];
    if ([model.sex isEqualToString:@"1"]) {
        self.AgeLB.text = [NSString stringWithFormat:@"♂%@", model.age];
    }else{
        self.AgeLB.text = [NSString stringWithFormat:@"♀%@", model.age];
    }
    self.CityLB.text = model.cityid;
    if (model.hello) {
        [self.sayHiBtn setTitle:@"已打招呼" forState:UIControlStateNormal];
        [self.sayHiBtn setTitleColor:RGB(0xF95880) forState:UIControlStateNormal];
        self.sayHiBtn.layer.borderColor = RGB(0xF95880).CGColor;
        
    }else{
        [self.sayHiBtn setTitle:@"HI 打招呼" forState:UIControlStateNormal];
        [self.sayHiBtn setTitleColor:RGB(0xA3A3A3) forState:UIControlStateNormal];
        self.sayHiBtn.layer.borderColor = RGB(0xA3A3A3).CGColor;
    }
}

- (void)awakeFromNib {
    
    [super awakeFromNib];
    
    self.sayHiBtn.layer.cornerRadius = 10;
    self.sayHiBtn.layer.masksToBounds = YES;
    self.sayHiBtn.layer.borderWidth = 1;
    self.sayHiBtn.layer.borderColor = RGB(0xF95880).CGColor;
    
    // Initialization code
}

- (IBAction)sayhiBtnClick:(id)sender {
    if ([_delegate respondsToSelector:@selector(clickSayHiWith:withIndex:)]) {
        [_delegate clickSayHiWith:self.model withIndex:self.indexPath];
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


@end
